package com.example.ujsfish.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.example.ujsfish.R;
import com.example.ujsfish.model.poolMap.PoolPoint;

import java.util.List;


public class PoolPointAdapter extends ArrayAdapter<PoolPoint> {

    private int resourceId;

    public PoolPointAdapter(@NonNull Context context, int resource, @NonNull List<PoolPoint> objects) {
        super(context, resource, objects);
        resourceId = resource;
    }


    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        PoolPoint poolPoint = getItem(position); //获取当前项的PoolPoint实例
        View view = LayoutInflater.from(getContext()).inflate(resourceId,parent,false);
        TextView index = view.findViewById(R.id.index);
        TextView point = view.findViewById(R.id.point);
        index.setText("第" + poolPoint.getPool_id() + "坐标点:");
        point.setText("X:" + poolPoint.getPoint_X() + ", y:" + poolPoint.getPoint_Y());
        return view;
    }

}
